package com.hjq.service.impl;

import com.hjq.mapper.ClazzMapper;
import com.hjq.mapper.EmpMapper;
import com.hjq.mapper.ReportMapper;
import com.hjq.mapper.StudentMapper;
import com.hjq.pojo.ClazzOption;
import com.hjq.pojo.JobOption;
import com.hjq.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.Objects;

@Service
public class ReportServiceImpl implements ReportService {
    @Autowired
    private EmpMapper empMapper;
    @Autowired
    private StudentMapper studentMapper;
    @Autowired
    private ClazzMapper clazzMapper;

    @Override
    public JobOption getEmpJobData() {
        List<Map<String, Object>> mapList = empMapper.getEmpJobData();
        List<String> pos = mapList.stream().map(item -> String.valueOf(item.get("pos"))).toList();
        List<Object> total = mapList.stream().map(item -> item.get("total")).toList();
        return new JobOption(pos,total);
    }

    @Override
    public List<Map<String, Object>> getEmpGenderData() {
        return empMapper.getEmpGenderData();
    }

    @Override
    public List<Map<String, Object>> studentDegreeData() {
        return studentMapper.studentDegreeData();
    }

    @Override
    public ClazzOption getStudentCountData() {
        List<Map<String, Object>> studentCountData = clazzMapper.getStudentCountData();
        List<String> names = studentCountData.stream().map(item -> String.valueOf(item.get("name"))).toList();
        List<Object> values = studentCountData.stream().map(item -> item.get("value")).toList();
        return new ClazzOption(names, values);
    }
}
